package com.hly.versioncontroladmin.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hly.versioncontroladmin.domain.Bo.VcCategoryBo;
import com.hly.versioncontroladmin.domain.VcCategory;
import com.hly.versioncontroladmin.mapper.VcCategoryMapper;
import com.hly.versioncontroladmin.result.PageQuery;
import com.hly.versioncontroladmin.service.VcCategoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class VcCategoryServiceImpl extends ServiceImpl<VcCategoryMapper, VcCategory> implements VcCategoryService {

    @Override
    public Page<VcCategory> listQuery(PageQuery<VcCategory> pageQuery, VcCategoryBo categoryBo) {
        Page<VcCategory> page = buildQueryWrapper(categoryBo).page(pageQuery.builderPage());
        return page;
    }

    public LambdaQueryChainWrapper<VcCategory> buildQueryWrapper(VcCategoryBo categoryBo){
        LambdaQueryChainWrapper<VcCategory> queryChainWrapper = lambdaQuery()
                .like(categoryBo.getVcKey() != null, VcCategory::getVcKey, categoryBo.getVcKey())
                .like(categoryBo.getInfo() != null, VcCategory::getInfo, categoryBo.getInfo());
        return queryChainWrapper;
    }

}
